//
//  CurrentUser.m
//  mentor
//
//  Created by 孙宏峰的MacPro on 2018/7/3.
//  Copyright © 2018年 孙宏峰的MacPro. All rights reserved.
//

#import "CurrentUser.h"

@interface CurrentUser ()
/*!@brief ****   用户基本信息属性 */
@property (nonatomic,strong)NSDictionary * itemDic;

@end
@implementation CurrentUser
static CurrentUser * sharedInstance = nil;

+(CurrentUser *)shared
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[CurrentUser alloc] init];
    });
    return sharedInstance;
}

/*!@brief ****  登录成功  */
-(void)onLoginSuccess:(NSDictionary *)result
{
    self.token = result[@"token"];
    self.showUserName = result[@"userInfo"][@"showUserName"];
    self.userType = result[@"userInfo"][@"userType"];
    
    if( [result[@"userInfo"][@"xingb"] trim].length < 1)
    {
        self.xingb = @"男";
    }else
    {
        self.xingb = [result[@"userInfo"][@"xingb"] trim];
    }
    if([self.userType isEqualToString:@"manager"]) { /*!@brief ****   小秘端 */
        self.itemStr1 = @"导师";
        self.itemStr2 = @"学生";
        self.itemStr3 = @"运营服务";
    }else if ([self.userType isEqualToString:@"mentor"]) { /*!@brief ****   导师端 */
        self.itemStr1 = @"首页";
        self.itemStr2 = @"导师端";
        self.itemStr3 = @"我的预约";
    }else { /*!@brief ****   家长端 */
        self.itemStr1 = @"首页";
        self.itemStr2 = @"家长端";
        self.itemStr3 = @"我的预约";
    }
}
- (NSArray *)itemArrs
{
    return self.itemDic[self.userType];
}
/*!@brief ****  退出登录  */
-(void)onLogout
{
    self.token = @"";
    
}
-(NSDictionary *)itemDic
{
    if(!_itemDic) {
        _itemDic = @{
                     @"manager":@[
                             @{@"title":@"导师",@"img":@"teacher_normal",@"selectImg":@"teacher_select"},
                             @{@"title":@"学生",@"img":@"child_normal",@"selectImg":@"child_select"},
                             @{@"title":@"运营管理",@"img":@"settings_normal",@"selectImg":@"settings_select"},
                                ],
                     @"mentor":@[
                             @{@"title":@"首页",@"img":@"home_normal",@"selectImg":@"home_select"},
                             @{@"title":@"导师端",@"img":@"teacher_normal",@"selectImg":@"teacher_select"},
                             @{@"title":@"我的预约",@"img":@"schedule_normal",@"selectImg":@"schedule_select"},
                             ],
                     @"parent":@[
                             @{@"title":@"首页",@"img":@"home_normal",@"selectImg":@"home_select"},
                             @{@"title":@"家长端",@"img":@"child_normal",@"selectImg":@"child_select"},
                             @{@"title":@"我的预约",@"img":@"schedule_normal",@"selectImg":@"schedule_select"},
                             ]
                     };
    }
    return _itemDic;
}
@end
